Skip to content

[CXF-7653]:Fix NPE in ClientProxy#414

Closed
jimma wants to merge 1 commit intoapache:masterfrom
jimma:master
Closed

[CXF-7653]:Fix NPE in ClientProxy#414
jimma wants to merge 1 commit intoapache:masterfrom
jimma:master

Conversation

@jimma
Copy link
Contributor

@jimma jimma commented May 2, 2018

… from provider endpoint

}

if (resList == null
if (Boolean.getBoolean(CHECK_EMTPY_RESPONSE) && resList == null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it goes through a Properties access so it is synchronized, maybe read it once per client instance to avoid an useless locking?

@jimma jimma force-pushed the master branch 2 times, most recently from d86f72a to bb1f9d4 Compare May 2, 2018 07:41
@jimma
Copy link
Contributor Author

jimma commented May 2, 2018

@rmannibucau Thanks for review. You are right. I improved the code a bit, please check if it's good now.

@jimma jimma requested review from coheigea and dkulp May 2, 2018 08:23
@rmannibucau
Copy link
Contributor

Was more thinking about doing it in the constructor but works for me

@coheigea
Copy link
Contributor

coheigea commented May 2, 2018

The problem with this patch is that the default behaviour is still to throw a NPE in CXF - i.e. remove the change to the test in systests/uncategorized and you get a NPE. Perhaps instead we need to revisit the original fix.

@jimma jimma changed the title [CXF-7653]:Add system property to enable/disable check empty response… [CXF-7653]:Fix NPE in JaxWsClientProxy May 3, 2018
@jimma
Copy link
Contributor Author

jimma commented May 3, 2018

@coheigea I wrongly thought this was an specific issue and it isn't. Looked at again and found this is actually caused by the null value return for primitive type in InvocationHandler(ClientProxy) :

If the value returned by this method is {@code null} and the interface method's return type is
primitive, then a {@code NullPointerException} will be thrown by the method invocation on the proxy instance.

Please review again. Thanks.

@jimma jimma force-pushed the master branch 2 times, most recently from 10baa23 to 01389cf Compare May 3, 2018 07:26
@jimma jimma changed the title [CXF-7653]:Fix NPE in JaxWsClientProxy [CXF-7653]:Fix NPE in ClientProxy May 3, 2018
} else {
result = invokeSync(method, oi, params);
}
if (result == null && !method.getReturnType().equals(Void.TYPE)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: you can use == to check class equality

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for review. @andrei-ivanov . I agree with you, == is more direct for class equality.

}

Object o = invokeSync(method, oi, params);
if (o == null && !method.getReturnType().equals(Void.TYPE) && method.getReturnType().isPrimitive()) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: you can use == to check class equality

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 .

throw new IllegalStateException("Response message did not contain proper response data. Expected: "
+ boi.getOutput().getMessageParts().get(0).getConcreteName());
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is all this code removed? If the WSDL states that there should be a response and there isn't, an exception should be thrown. The above is correct. By pushing some of this down into the ClientProxy's, anything that doesn't use the client proxies (like Camel endpoints) wouldn't have this check in place.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is all this code removed? If the WSDL states that there should be a response and there isn't, an exception should be thrown. The above is correct.

When I ran reproducer EmptySoapBodyTest and found the NPE is thrown from Proxy class and root cause for this NPE is a null return value for a primitive type in InvocationHandler(ClientProxy), that's why I remove this and add this check in ClientProxy. I only looked at EmptySoapBodayTest , any other reproducer I need to have a look for CXF-7653 ?

Another reason why I remove these lines is this check doesn't work for this case: for example we have a simple wsdl which generates the following operation :

public HelloResponse doSomething(HelloRequest request);

To work with Dispatch/Provider , a provider class created to simply return an empty StreamSource like:

@WebServiceProvider(
          serviceName="HelloService",
          portName="HelloPort",
          targetNamespace="http://cxf.apache.org/provider",
          wsdlLocation="WEB-INF/hello.wsdl"
  )
@BindingType(value=javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING)
@ServiceMode (value=javax.xml.ws.Service.Mode.PAYLOAD)
public class HelloProvider implements Provider<Source> {
  public Source invoke(Source req)  {
      return new StreamSource();
  }
}

The client dispatch expects receiving a null value. Add this check in ClientImpl throws IllegalStateException instead of return a null result.

By pushing some of this down into the ClientProxy's, anything that doesn't use the client proxies (like Camel endpoints) wouldn't have this check in place.

For the caml endpoints without using the client proxy, it gets a null value result. Is the null value a problem for ClientCallback and something else ?

@jimma
Copy link
Contributor Author

jimma commented May 4, 2018

After talked with @dkulp and @coheigea , looked at more details . This PR possibly doesn't fix CXF-7653 completely and probably has other side effect. I'll close this PR and fix the issue after CXF-7653 with another PR #417.

@jimma jimma closed this May 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants